package com.sjzd.message;

import com.sjzd.entity.Tank;
import com.sjzd.exception.NullObjectException;
import com.sjzd.menu.GameMenu;


public class TankMessageProcessStrategy extends MessageProcessStrategy<TankStatusMessage> {
    public TankMessageProcessStrategy(GameMenu gameMenu) {
        super(gameMenu);
    }

    @Override
    public void process(TankStatusMessage msg) throws NullObjectException {
        Tank tank = gameMenu.getOtherTank(msg.id);
        if (!msg.isExist) {
            tank.isExist = false;
            gameMenu.removeTank(msg.id);
        } else {
            tank.X = msg.X;
            tank.Y = msg.Y;
            tank.sinX = msg.sinX;
            tank.sinY = msg.sinY;
        }
    }
}
